The following examples are for a new dialog called "Dialog1". Use the tools on the Toolbox bar in the dialog editor to create the dialog and add the following controls: a Check Box called "CheckBox1", a Label Field called "Label1", a Button called "CommandButton1", and a List Box called "ListBox1".
下記の例は、「Dialog1」と名付けた新規ダイアログを制御するためのものです。 このダイアログを作成する際には、ダイアログエディタ上で コントロール 可動ツールバーを表示させ、該当するツールを用いて、次のコントロールを配置しておきます: 「CheckBox1」という名前の チェックボックス 1 個、「Label1」という名前の ラベルフィールド (図表番号ボックス) 1 個、「CommandButton1」という名前の ボタン 1 個、「ListBox1」という名前の リストボックス 1 個。
![]() | Be consistent with uppercase and lowercase letter when you attach a control to an object variable.
オブジェクト変数にコントロールを割り当てる際には、上記の名前の大文字と小文字を一致させる必要があります。 |
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object
Dim oLib as Object
Dim oLibDialog as Object
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
Dim oRuntimeDialog as Object
If IsMissing(oLibContainer ) then
If IsMissing(oLibContainer ) then
oLibContainer = DialogLibraries
oLibContainer = DialogLibraries
End If
End If
oLibContainer.LoadLibrary(LibName)
oLibContainer.LoadLibrary(LibName)
oLib = oLibContainer.GetByName(Libname)
oLib = oLibContainer.GetByName(Libname)
oLibDialog = oLib.GetByName(DialogName)
oLibDialog = oLib.GetByName(DialogName)
oRuntimeDialog = CreateUnoDialog(oLibDialog)
oRuntimeDialog = CreateUnoDialog(oLibDialog)
LoadDialog() = oRuntimeDialog
LoadDialog() = oRuntimeDialog
End Function
End Function
rem global definition of variables
rem 変数の大域定義
Dim oDialog1 AS Object
Dim oDialog1 AS Object
Sub StartDialog1
Sub StartDialog1
BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1.Execute()
oDialog1.Execute()
end sub
end sub
Sub Sample1
Sub Sample1
BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")
REM get dialog model
REM ダイアログモデルの取得
oDialog1Model = oDialog1.Model
oDialog1Model = oDialog1.Model
REM display text of Label1
REM Label1 のテキストの表示
oLabel1 = oDialog1.GetControl("Label1")
oLabel1 = oDialog1.GetControl("Label1")
MsgBox oLabel1.Text
MsgBox oLabel1.Text
REM set new text for control Label1
REM Label1 のテキストの変更
oLabel1.Text = "New Files"
oLabel1.Text = "New Files"
REM display model properties for the control CheckBox1
REM CheckBox1 コントロールのモデルプロパティーの表示
oCheckBox1Model = oDialog1Model.CheckBox1
oCheckBox1Model = oDialog1Model.CheckBox1
MsgBox oCheckBox1Model.Dbg_Properties
MsgBox oCheckBox1Model.Dbg_Properties
REM set new state for CheckBox1 for model of control
REM コントロールモデルでの CheckBox1 の状態の変更
oCheckBox1Model.State = 1
oCheckBox1Model.State = 1
REM display model properties for control CommandButton1
REM CommandButton1 コントロールのモデルプロパティーの表示
oCMD1Model = oDialog1Model.CommandButton1
oCMD1Model = oDialog1Model.CommandButton1
MsgBox oCMD1Model.Dbg_Properties
MsgBox oCMD1Model.Dbg_Properties
REM display properties of control CommandButton1
REM CommandButton1 コントロールの表示
oCMD1 = oDialog1.GetControl("CommandButton1")
oCMD1 = oDialog1.GetControl("CommandButton1")
MsgBox oCMD1.Dbg_Properties
MsgBox oCMD1.Dbg_Properties
REM execute dialog
REM ダイアログの実行
oDialog1.Execute()
oDialog1.Execute()
End Sub
End Sub
Sub AddEntry
Sub AddEntry
BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")
REM adds a new entry to the ListBox
REM リストボックスへの項目追加
oDialog1Model = oDialog1.Model
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
oListBox = oDialog1.GetControl("ListBox1")
dim iCount as integer
dim iCount as integer
iCount = oListbox.ItemCount
iCount = oListbox.ItemCount
oListbox.additem("New Item" & iCount,0)
oListbox.additem("New Item" & iCount,0)
end sub
end sub
Sub RemoveEntry
Sub RemoveEntry
BasicLibraries.LoadLibrary("Tools")
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1 = LoadDialog("Standard", "Dialog1")
REM remove the first entry from the ListBox
REM リストボックスの 1 番目の項目の削除
oDialog1Model = oDialog1.Model
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
oListBox = oDialog1.GetControl("ListBox1")
oListbox.removeitems(0,1)
oListbox.removeitems(0,1)
end sub
end sub